var mapIds = [993173200];
var 准备地图 = 993173350;

function init() {}

function setup(c, a) {
    em.setProperty("state", 1);
    em.setProperty("leader", "true");
    var c = em.newInstance("荣耀活动_塞尔提乌城墙_阻止怪物海鸥");
    for (var b = 0; b < mapIds.length; b++) {
        var d = c.setInstanceMap(mapIds[b]);
        d.resetFully()
    }
    c.schedule("海鸥准备", 3 * 1000);
    return c
}

function 海鸥准备(a) {
    a.schedule("海鸥出现", 6 * 1000);
    a.getPlayers().forEach(function (b) {
        b.getAPI().getWeatherEffectNotice("巨大怪物海鸥向着城墙飞去了！请准备发射弩！", 297, 5000, 1);
        b.getAPI().playerMessage(5, "巨大怪物海鸥向着城墙飞去了！请准备发射弩！")
    })
}

function 海鸥出现(a) {
    a.schedule("海鸥逃走", 75 * 1000);
    em.setProperty("harm", 0);
    var b = 0;
    a.getPlayers().forEach(function (d) {
        if (b++ == 0) {
            for (var c = 0; c < 5; c++) {
                d.getMap().getReactorByName("ballista" + c).forceHitReactor(d, 1)
            }
            d.getAPI().spawnMobLimit(9833636, 1, 1515, -382, 1)
        }
        d.getAPI().getWeatherEffectNotice("巨大怪物海鸥出现了。请点击[采集键]使用魔法弩！", 297, 7000, 1);
        d.getAPI().playerMessage(5, "巨大怪物海鸥出现了。请点击[采集键]使用魔法弩！");
        d.getAPI().cerniumBefenseBirdStart();
        d.getAPI().getClockCerniumBird(75)
    })
}

function 海鸥坠落(a) {
    var b = 0;
    a.getPlayers().forEach(function (d) {
        if (b++ == 0) {
            for (var c = 0; c < 5; c++) {
                d.getMap().getReactorByName("ballista" + c).forceHitReactor(d, 1)
            }
            var e = d.getMap().getMonsterById(9833636).getPosition();
            d.getMap().killMonster(9833636, false, true);
            d.getAPI().spawnMobLimit(9833637, 1, e.x, e.y, 0)
        }
        d.getAPI().getWeatherEffectNotice("巨大怪物海鸥坠落了！请发动直接攻击！", 297, 5000, 1);
        d.getAPI().playerMessage(5, "巨大怪物海鸥坠落了！请发动直接攻击！");
        d.getAPI().fieldEffect_Tremble(1, 0, 30)
    })
}

function 海鸥逃走(a) {
    var c = a.getMapInstance(0);
    if (c.countMonsterById(9833636, 9833637) == 0) {
        return
    }
    a.schedule("海鸥准备", 60 * 1000);
    c.killMonster(9833636, false, true);
    c.killMonster(9833637, false, true);
    var b = 0;
    a.getPlayers().forEach(function (e) {
        if (b++ == 0) {
            for (var d = 0; d < 5; d++) {
                e.getMap().getReactorByName("ballista" + d).forceHitReactor(e, 0)
            }
        }
        e.getAPI().getWeatherEffectNotice("巨大怪物海鸥逃走了。", 297, 5000, 1);
        e.getAPI().playerMessage(5, "巨大怪物海鸥逃走了。");
        e.getAPI().cerniumBefenseBirdStop();
        e.getAPI().showStalkResult(14)
    })
}

function 海鸥死亡(a) {
    a.schedule("海鸥准备", 60 * 1000);
    a.getPlayers().forEach(function (b) {
        b.getAPI().getWeatherEffectNotice("你已击退巨大怪物海鸥。", 297, 5000, 1);
        b.getAPI().playerMessage(5, "你已击退巨大怪物海鸥。");
        b.getAPI().cerniumBefenseBirdStop();
        b.getAPI().showStalkResult(14)
    })
}

function onPlayerRegistered(b, a) {
    a.setReviveCount(-100);
    var c = b.getMapInstance(0);
    a.changeMap(c, c.getPortal(0))
}

function onPlayerRevived(b, a) {
    return false
}

function onMapChanged(c, b, a) {
    em.setProperty("kill", "0");
    em.setProperty("level", "0");
    em.setProperty("clear", "0");
    em.setProperty("curMap", a);
    if (mapIds.indexOf(a) < 0) {
        on玩家退场(c, b, false);
        return
    }
}

function onPlayerDisconnected(b, a) {
    on玩家退场(b, a, false);
    return 0
}

function onMonsterDamaged(c, b, e, f, d) {
    if (e == 9833636) {
        var a = em.getNumberProperty("harm") + 1;
        if (a == 6) {
            c.schedule("海鸥坠落", 0);
            em.setProperty("harm", a)
        } else {
            em.setProperty("harm", 0)
        }
    }
}

function onTimeOut(a) {
    a.getPlayers().forEach(function (b) {
        on玩家退场(a, b, true)
    })
}

function onMonsterKilled(b, d, c) {
    var a = em.getNumberProperty("kill") + 1;
    em.setProperty("kill", a);
    if (d == 9833637) {
        b.schedule("海鸥死亡", 0)
    }
}

function onPartyDisbanded(a) {}

function onPlayerKilled(b, a) {}
var setupTask;

function randomNum(b, a) {
    switch (arguments.length) {
        case 1:
            return parseInt(Math.random() * b + 1, 10);
            break;
        case 2:
            return parseInt(Math.random() * (a - b + 1) + b, 10);
            break;
        default:
            return 0;
            break
    }
}

function initProp(a, b) {
    if (em.getProperty(a) == null) {
        em.setProperty(a, b)
    }
}

function initPropArray(a, d, c, e) {
    for (var b = c; b <= e; b++) {
        if (em.getProperty(a + "_" + b) == null) {
            em.setProperty(a + "_" + b, d)
        }
    }
}

function on玩家退场(c, b, a) {
    c.disposeIfPlayerBelow(a ? 999 : 0, 准备地图);
    em.getProperties().clear();
    em.setProperty("state", 0);
    em.setProperty("leader", "true");
    c.unregisterPlayer(b)
}

function onItemPickedUp(b, a, c) {};